<template>
  <div>
    <button @click="getStus">获取学生信息</button>
    <button @click="getCars">获取汽车信息</button>
  </div>
</template>

<script>
import axios from 'axios';
export default {
  name: 'App',
  // http://localhost:8080/students
  // http://localhost:8080/demo/cars
  methods: {
    getStus() {
      // 解决跨域 代理服务器 (方式一)
      axios.get('http://localhost:8081/api/students').then(
        response=>{
          console.log('请求成功了',response.data);
        },
        error=>{
          console.log('请求失败了',error.message);
        }
      );
      //方式二

    },
    getCars() {
      axios.get('http://localhost:8081/demo/cars').then(
        response=>{
          console.log('请求成功了',response.data);
        },
        error=>{
          console.log('请求失败了',error.message);
        }
      );
      //方式二

    },
  },
};
</script>
